/*
 * CodeList.cpp
 *
 *  Created on: 4 May 2010
 *      Author: Savramis Sartios
 */

#include "CodeList.h"
#include "../../../Exceptions/NullPointer.h"
#include "../Iterator/CodeListIterator.h"
#include "../../../Exceptions/OutOfBound.h"

CodeList::CodeList(){

}/*
CodeList::CodeList(const vector<string*> *codeList) {
	setCodeList(codeList);
}
*/
CodeList::~CodeList() {
	/*delete	this;*/
}
/*
bool CodeList::setCodeList(const vector<string*> *codeList){
	if(0!=codeList){
		codeList_=new vector<string*>(*codeList);
		return true;
	}
	throw NullPointer("vector can't be null");
}*/

bool CodeList::add(const string *code){
	if(0!=code){
		codeList_.push_back(*code);
		return true;
	}
	throw NullPointer("code can't be null");
}

int CodeList::count()const{
	return codeList_.size();
}

string  CodeList::getElement(const int position)const{
	if((-1<position)&&(position<codeList_.size())){
		return codeList_.at(position);
	}
	throw OutOfBound("Position out of bound");
}

ICodeIterator * CodeList::getIterator(){
	return new CodeListIterator((ICodeList*)this);
}
